<?php
namespace Android\Model;

class TimetableModel extends BaseModel {

    /**
     * 获取指定教学计划课表周数
     *
     * @param $teachplan_id
     * @return integer $weeks
     */
    public function getWeeksByTid ($teachplan_id) {
        $weeks = $this->where('teachplan_id = ' . $teachplan_id)->order('week desc')->limit(1)->getField('week');
        if (empty($weeks))
            return 0;
        return intval($weeks);
    }


    public function getTimetableByWhere($where) {
        return $this->where($where)->select();
    }


    /**
     * 获取指定教学计划周课表
     *
     * @param $teachplan_id
     * @param $week
     * @return mixed
     */
    public function getTimetable ($teachplan_id,$week) {

        $map['teachplan_id'] = $teachplan_id;
        $map['week'] = $week;
        $timetables = $this->where($map)->order('xq asc, start asc')->select();
        return $timetables;

    }





}